package top.kaoshanji.p2ch10a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.p2ch10a.support.ToBeCloned;

/**
 * 代码清单-p2ch10a-319页a：Object类的clone方法的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/2 20:09
 */
public class SimpleClone {

    private static final Logger logger = LogManager.getLogger(SimpleClone.class);

    public static void main(String[] args) {
        logger.info("...代码清单-p2ch10a-319页a：Object类的clone方法的使用示例...");

        SimpleClone sc = new SimpleClone();
        sc.cloneObject();

    }

    public void cloneObject() {
        ToBeCloned obj = new ToBeCloned();
        obj.setValue(1);

        ToBeCloned clonedObj = (ToBeCloned)obj.clone();
        System.out.println(clonedObj.getValue());

    }

}
